package communicationMessages;

import java.sql.ResultSet;

import database.DB;

public class AdminCandidateMessage extends Message {

	@Override
	public String getAnswer() {
		String ans = "adminCandidate" + delimiter;
		String wrongFromat = "wrong format" + delimiter;
		String []arr =this.content.split(delimiter);
		if (arr.length != 1)
		{
			ans+=wrongFromat;
		}
		else
		{
			String userName = arr[0];
			if (!DB.isAdmin(userName))
			{
				ans+= wrongFromat;
			}
			else
			{
				String userRoll = "admin" + delimiter;
				ans+= userRoll;
				ResultSet res = DB.getAdminCandidates();
				ans = getUsersNameFromResultSet(ans, res);
			}
		}
		return ans;
	}

}
